/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_CORE_COMMON_RUNTIME_NEXT_PLUGGABLE_DEVICE_C_EXAMPLE_PLUGIN_H_
#define TENSORFLOW_CORE_COMMON_RUNTIME_NEXT_PLUGGABLE_DEVICE_C_EXAMPLE_PLUGIN_H_

#include "tensorflow/core/common_runtime/next_pluggable_device/c/plugin_c_api.h"
#include "tfrt/host_context/host_context.h"  // from @tf_runtime

// This is an example plugin that impelements several basic APIs for event. This
// is for testing only.

#ifdef __cplusplus
extern "C" {
#endif

struct TFNPD_DeviceEvent {
  tfrt::RCReference<tfrt::AsyncValue> event;
};

// Does not pass ownership of returned TFNPD_Api* to caller.
const TFNPD_Api* GetExamplePluginApi();

#ifdef __cplusplus
}
#endif

namespace example_plugin {

// A helper method that generates a TFNPD_DeviceEvent, and makes the event
// available (or ready) in two seconds.
TFNPD_DeviceEvent* CreateDeviceEventAndSetAvailable(tfrt::HostContext* host,
                                                    bool set_as_error = false);

}  // namespace example_plugin

#endif  // TENSORFLOW_CORE_COMMON_RUNTIME_NEXT_PLUGGABLE_DEVICE_C_EXAMPLE_PLUGIN_H_
